package com.xctech.yace.service;

import org.apache.kafka.clients.consumer.KafkaConsumer;

import java.io.IOException;
import java.util.Properties;

public class KafkaConsumerDemo {
    public static void main(String[] args) throws IOException {
        Properties props = new Properties();
        System.setProperty("java.security.auth.login.config", "E:/Workspace/Clearing/yace/conf/kerberos/kafka_server_jaas.conf");
        System.setProperty("java.security.krb5.conf", "E:/Workspace/Clearing/yace/conf/kerberos/krb5.conf");

//        org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
//        conf.set("hadoop.security.authentication", "Kerberos");
//        UserGroupInformation.setConfiguration(conf);
//        UserGroupInformation.loginUserFromKeytab("flink@XUNCE.COM", "E:/Workspace/Clearing/yace/conf/kerberos/xunce.keytab");

        props.put("bootstrap.servers", "192.168.0.105:9092");
        props.put("group.id ", "yace");
        props.put("key.deserializer", " org.apache.kafka.common.serialization.StringDeserializer");
        props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

        props.put("security.protocol", "SASL_PLAINTEXT");
        props.put("sasl.kerberos.service.name", "kafka");
        props.put("sasl.mechanism", "GSSAPI");
        KafkaConsumer<String,String> consumer = new KafkaConsumer<String, String>(props);

    }
}
